package org.boulderfoodrescue.webapp.client.old.event;

import org.boulderfoodrescue.webapp.shared.Place;

import com.google.gwt.event.shared.GwtEvent;

public class PlaceChangedEvent extends GwtEvent<PlaceChangedHandler>{

  private static final Type<PlaceChangedHandler> TYPE = new Type<PlaceChangedHandler>();
  private Place place;
  private Boolean added;
  
  public PlaceChangedEvent(Place place, Boolean added) {
    this.place = place;
    this.added = added;
  }

  public static Type<PlaceChangedHandler> getType() {
    return TYPE;
  }

  @Override
  public com.google.gwt.event.shared.GwtEvent.Type<PlaceChangedHandler> getAssociatedType() {
    return TYPE;
  }

  @Override
  protected void dispatch(PlaceChangedHandler handler) {
    if(added == null)
      handler.onPlaceUpdate(this);
    else if(added)
      handler.onPlaceAdded(this);
    else
      handler.onPlaceRemoved(this);
  }

  public Place getPlace() {
    return place;
  }

  public Boolean getAdded() {
    return added;
  }
}
